<template>
  <div class="app-container">
    <div v-if="crud.props.searchToggle">
      <el-input v-model="query.name" clearable size="small" placeholder="输入提名搜索" style="width: 200px;"
                class="filter-item" @keyup.enter.native="crud.toQuery"/>
      <rrOperation/>
    </div>
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
<!--      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="id">
            <el-input v-model="form.id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="docId">
            <el-input v-model="form.docId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="mnName">
            <el-input v-model="form.mnName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="zhName">
            <el-input v-model="form.zhName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="path">
            <el-input v-model="form.path" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="page">
            <el-input v-model="form.page" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="number">
            <el-input v-model="form.number" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="updateBy">
            <el-input v-model="form.updateBy" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="updateTime">
            <el-input v-model="form.updateTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="createBy">
            <el-input v-model="form.createBy" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="createTime">
            <el-input v-model="form.createTime" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>-->
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="id" label="id" />
        <el-table-column prop="docId" label="古籍文献编号" />
        <el-table-column prop="mnName" label="蒙古文题名" />
        <el-table-column prop="zhName" label="中文提名" />
        <el-table-column prop="path" label="照片" align="center">
          <template slot-scope="scope">
            <el-image
              :src= "baseApi + '/file' +scope.row.path"
              :preview-src-list="[baseApi + '/file' + scope.row.path]"
              fit="contain"
              lazy
              class="el-avatar"
            >
              <div slot="error">
                <i class="el-icon-document"/>
              </div>
            </el-image>
          </template>

        </el-table-column>
        <el-table-column prop="page" label="页码" />
        <el-table-column prop="number" label="总目编号" />
        <el-table-column prop="remTime" label="删除时间" />
<!--        <el-table-column v-if="checkPer(['admin','docRemPicture:edit','docRemPicture:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>-->
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import crudDocRemPicture from '@/api/literatureManagement/docRemPicture'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, docId: null, mnName: null, zhName: null, path: null, page: null, number: null, updateBy: null, updateTime: null, createBy: null, createTime: null }
export default {
  name: 'DocRemPicture',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '图片删除', url: 'api/docRemPicture', idField: 'id', sort: 'id,desc', crudMethod: { ...crudDocRemPicture }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'docRemPicture:add'],
        edit: ['admin', 'docRemPicture:edit'],
        del: ['admin', 'docRemPicture:del']
      },
      rules: {
      }    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  },
  computed: {
    ...mapGetters([
      'baseApi',
      'fileUploadApi',
      'imagesUploadApi'
    ])
  }
}
</script>

<style scoped>

</style>
